<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglibs.jsp" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%> 
<s:if test="@org.springside.modules.security.springsecurity.SpringSecurityUtils@getCurrentUserName() == 'anonymousUser'">
	<s:include value="/admin/login.jsp" />
</s:if> <s:else>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>通知公告</title>
<style type="text/css">
.main{
  height:100%;
}
.data_more{float: right;}
.data_more a{
  padding: 2px 0 0 15px;
  margin-right: 21px;
}
.data_more .upload{background: url(${ctx }/images/body_main_operate_selectall_p.png) 0 8px no-repeat;}
.data_more .choice_all{background: url(${ctx }/images/body_main_operate_selectall_p.png) 0 8px no-repeat;}
.data_more .choice_a{background: url(${ctx }/images/body_main_operate_selectall_p.png) 0 8px no-repeat;}
.data_more .delect{background: url(${ctx }/images/body_main_operate_delete_p.png) 0 8px no-repeat;}
.data_more .add{background: url(${ctx }/images/body_main_operate_add_p.png) 0 8px no-repeat;
  color: white;
}
#users{
  border-collapse: collapse;
  width: 100%;
  border: 0 none;
  border-spacing: 0;
}
#users .title_bg{
  color: #010000;
  background-color: #e8e7e7;
  border-bottom: 1px solid #fff;
  font-size: 15px;
}
#users td{
  border-left: 1px solid #e2e2e2;
  padding: 5px;
  text-align: center;
}
#users .add_td{background: #eaeaea;}
#users .table_content{}

#users .name_part{
  display: none;
}
#users .notitle_change a{}
#users .notitle_change input{
  border: 1px solid #ccc;
}
#users .yes,#users .no{
  display: inline-block;
  width: 10px;
  height:10px;
  margin: 0 2px;
  background: red;
}
</style>

<link href="${ctx }/css/public.css" rel="stylesheet" type="text/css" />
  
</head>
 

<body>
	<div class="main">
		<div class="tip">
      <span class="data_more">
      <a  class="choice_a" >全选</a>
        <a  class="choice_all" >反选</a>
        <a  class="delect" >删除</a>
        <a class="add" href="${ctx }/admin/announcement-admin!show1.action"  target="mainFrame">添加</a>
      </span>  
      <span>所在位置 :</span>
      <span class="current_position">通知公告列表</span> 
    </div>
    <table id="users">
      <thead>
        <tr class="title_bg">
            <td width="3%">
                <a class="right-font08">序号</a>
            </td>
            <td width="20%">公告标题</td>
            <td width="7%">发布时间</td>
            <td width="10%">操作</td>
        </tr>
      </thead>
      <s:iterator value="announcementList" id="a">
      <tbody id="json_list">
        <tr class="control_list">
          <td class="notitle_border">
            <input type="checkbox" name="delid" id="${a.id}" class="checkbox">
          </td>
          <td class="notitle_border">
         <%--    <span title="a.title">${a.title}${fn:substring(a.editTime, 2, 10)}</span> --%>
          <span title="${a.title}">${fn:substring(a.title,0, 20)}</span>
          </td>
          <td class="notitle_border">${a.editTime}</td>
          <td class="notitle_border">
            <a href="${ctx }/admin/announcement-admin!show.action?id=${a.id}"  target="mainFrame">编辑</a>|
            <a href="${ctx }/admin/announcement-admin!delete.action?id=${a.id}&type=u&currentpage=${pageNo}" onclick="return confirm('确定删除吗？')">删除</a>
          </td>
        </tr>
         
      </tbody>
      </s:iterator>
    </table>
    <div class="page">
      <div class="page_middle">
      <div class="page_lay">
        <a href="${ctx }/admin/announcement-admin!list.action?currentpage=1" >首页</a>
        <a href="${ctx }/admin/announcement-admin!list.action?currentpage=${prePage}">上一页</a>
                    第<s:property value="pageNo" />/${totalPages }页
        <a href="${ctx }/admin/announcement-admin!list.action?currentpage=${nextPage}">下一页</a>
        <a href="${ctx }/admin/announcement-admin!list.action?currentpage=${totalPages }">尾页</a>
      </div>
      <input name="pages" id="pages" type="text" class="page_choice" />
      <input class="page_sure" type="button" onclick="go()" value=" ">
    </div>
    </div>
	</div>
	<script type="text/javascript" src="${ctx }/js/public.js"></script>
	 <script type="text/javascript">
	  tool("data_more","click");
	 function go(){
               var pages = document.getElementById("pages").value;//得到id为pages输入框的值 
               if(pages>"${totalPages}")
               {
               pages="${totalPages}";
               
               }
                if(pages <1)
               {
               pages=1;
               
               }
               location.href = "${ctx }/admin/announcement-admin!list.action?currentpage="+pages;
}
 function tool(obj,evt){
	//获取节点
	var obj = obj.nodeType ? obj : newdom.getElementsByClass(obj)[0];
	//console.log(obj.nodeType);
	switch(evt){
		//鼠标点击事件
		case "click" :
			obj.onclick = function(e){
				//获取事件触发元素
				var _e = window.event ? window.event : e || arguments[0],
					target = _e.target ? _e.target : _e.srcElement,
					json_list = newdom.$("json_list"),
					control_list = newdom.getElementsByClass("control_list"),
					checkbox = newdom.getElementsByClass("checkbox"),
					len_checkbox = checkbox.length;
				//选择所有工具
				if(target.className == "choice_all"){
					for(var i = 0;i < len_checkbox;i++){
					if(	checkbox[i].checked == true)
						{
						checkbox[i].checked=false;
						}
					else{
						checkbox[i].checked=true;
					}
					}
					
				}
				if(target.className == "choice_a"){
					for(var i = 0;i < len_checkbox;i++){
					
						checkbox[i].checked=true;
					}
					
				}
				//选择删除工具
				if(target.className == "delect"){

					var result = "";
					for(var i = 0;i < len_checkbox;i++){
						//如果被选中，删除所在行
						if(checkbox[i].checked == true && checkbox[i].id){
							result += checkbox[i].id + ";";

						}
					}
					result = result.substring(0, result.length - 1);
            
                 if (result == "") {
        alert("请选择要删除的记录");
    } 
   

    else if (confirm('删除后的数据不可恢复，请慎重选择！\n确定要删除吗？')){
         
        location.href = "${ctx }/admin/announcement-admin!deleteByIds.action?ids="+result+"&currentpage=${pageNo}";
    }
					 
				}
			}
		break;
		//鼠标在元素上面
		case "mouse" :
			//do something
		break;
	}
}
 
	</script>
</body>
</html>
</s:else>